Magic 8 Ball



Ever wanted to play with a JavaScript Magic 8 Ball? Well, here is a fully functional, and totally random, JavaScript Magic 8 Ball. Enjoy. 

--------------------------------------------------------------------------------
 

<!-- THREE STEPS TO INSTALL MAGIC 8 BALL:

   1.  Put the first code into the HEAD of your HTML document
   2.  Paste the final coding into the BODY of your HTML document
   3.  Save the 9 necessary images into your web directory  -->

<!-- STEP ONE: Copy this code into the HEAD of your HTML document  -->

<HEAD>

<SCRIPT LANGUAGE="JavaScript">

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!--  Begin
var sec = 0
var imgsrc
var output = "<BR>"
function getsec() {
var date = new Date()
sec = date.getSeconds()
}
function getnum() {
if (sec > 49) {
sec = sec - 50
}
else {
if (sec > 39){
sec = sec - 40
}
else {
if (sec > 29){
sec = sec - 30
}
else {
if (sec > 19){
sec = sec - 20
}
else {
if (sec > 9){
sec = sec - 10
}}}}}}
function display() {
imgsrc = '<img src="http://your.server.com/magic8/' + sec + '.gif">'
output += imgsrc
}
function doit(){
getsec();
getnum();
display();
document.write(output);
}
// End -->
</SCRIPT>

<!-- STEP TWO: Copy this code into the BODY of your HTML document  -->

<BODY>

<CENTER>
The Magic 8 Ball says...
<BR>
<SCRIPT>
doit();
</SCRIPT>
<BR>
<A HREF="magic8.html"><B>Get Another Prediction</B></A>
</CENTER>

<!-- STEP THREE: Copy the 9 following images into your web directory  -->

<!-- Point your browser at the following URLs, then save the images...     -->
<!-- http://javascript.internet.com/img/magic8/0.gif  --> 
<!-- http://javascript.internet.com/img/magic8/2.gif  -->
<!-- http://javascript.internet.com/img/magic8/3.gif  -->
<!-- http://javascript.internet.com/img/magic8/4.gif  -->
<!-- http://javascript.internet.com/img/magic8/5.gif  -->
<!-- http://javascript.internet.com/img/magic8/6.gif  -->
<!-- http://javascript.internet.com/img/magic8/7.gif  -->
<!-- http://javascript.internet.com/img/magic8/8.gif  -->
<!-- http://javascript.internet.com/img/magic8/9.gif  -->
</textarea><br></td></tr>
</table>
</form>

<p><center>
<font face="arial, helvetica" size="-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>

<!-- Script Size:  2.07 KB  -->
